﻿using System;
using XchangeStreamer.Core.Server;
using System.ServiceModel;
using XchangeStreamer.Core;

namespace XchangeStreamer.Server.Core
{
    internal sealed partial class Engine : IPublisher
    {
        #region Private Fields

        private int topicId = 0;

        #endregion
        
        #region IPublisher Members

        public void Publish(System.ServiceModel.Channels.Message message)
        {
            this.Notify(message);
        }

        public int CreateTopic(string topicName)
        {
            using (new WritableSynchronizer(this.sync, LockType.ReaderWriterLockSlim))
            {
                this.topicId++;
                this.subscribers.Add(this.topicId, new System.Collections.Generic.List<INotification>());
                return this.topicId;
            }
        }

        public void DeleteTopic(int topicId)
        {
            throw new NotImplementedException();
        }

        public void UpdateTopic(int topicId, string topicName)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
